package com.sinothk.gpserver.modules.comm.files.controller;

import com.sinothk.gpserver.modules.comm.files.entity.FileEntity;
import com.sinothk.gpserver.modules.comm.files.service.FileService;
import com.sinothk.server.support.annotation.callback.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 编写 Liang Y.T.
 * 时间 2021/11/19 0:23
 */
@Api(tags = "文件系统")
@Slf4j
@RestController
@RequestMapping("/file")
@ResponseResult()
public class FileController {
    @Autowired
    FileService fileService;

    /**
     * 文件上传-单文件
     *
     * @param bizType
     * @param file
     * @return
     */
    @ApiOperation(value = "文件上传-单文件", notes = "文件上传-单文件")
    @PostMapping(value = "/upload")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "file", value = "文件流对象,接收数组格式", dataType = "MultipartFile", allowMultiple = true),
            @ApiImplicitParam(name = "bizType", value = "业务分类")}
    )
    public FileEntity upload(@RequestParam("bizType") String bizType, @RequestParam("file") MultipartFile file) {
        FileEntity fileEntity = fileService.uploadFile(bizType, file);
        return fileEntity;
    }



}
